home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / HyperCuber 2.0 Source / CRotateMouseTask.cp < prev    next >
Encoding:
Text File  |  1994-04-06  |  3.1 KB  |  103 lines  |  [TEXT/KAHL]

  1. //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2. //| This file contains the implementation of the RotateMouseTask class.
  3. //|_____________________________________________________________________
  4.  
  5. #include "CControlsDirector.h"
  6. #include "CRotateMouseTask.h"
  7. #include "CHyperCuberPane.h"
  8.  
  9. //========================== Globals =========================\\
  10.  
  11. extern Boolean drawing_disabled;
  12.  
  13.  
  14.  
  15. //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  16. //| CRotateMouseTask::IRotateMouseTask
  17. //|
  18. //| Purpose: Initialize the mouse task.
  19. //|
  20. //| Parameters: h_mouse_tasks: the horizontal mouse controls
  21. //|             v_mouse_tasks: the vertical mouse controls
  22. //|             num_h_tasks:   number of horizontal controls
  23. //|             num_v_tasks:   number of vertical controls
  24. //|_______________________________________________________________________________
  25.  
  26. void CRotateMouseTask::IRotateMouseTask(CHyperCuberPane *the_pane, mouse_task_struct *h_mouse_tasks,
  27.                                         mouse_task_struct *v_mouse_tasks,
  28.                                         short num_h_tasks, short num_v_tasks)
  29. {
  30.  
  31.     CMouseTask::IMouseTask(0);                //  Initialize superclass
  32.  
  33.     pane = the_pane;
  34.  
  35.     h_tasks = h_mouse_tasks;
  36.     v_tasks = v_mouse_tasks;
  37.     num_h = num_h_tasks;
  38.     num_v = num_v_tasks;
  39.  
  40. }    //==== CRotateMouseTask::IRotateMouseTask() ====\\
  41.  
  42.  
  43.  
  44. //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  45. //| CRotateMouseTask::KeepTracking
  46. //|
  47. //| Purpose: This gets called regularly as long as the mouse button is down.
  48. //|
  49. //| Parameters: start_point:    point where button went down
  50. //|             previous_point: last registered location of cursor
  51. //|             current_point:  current location of cursor
  52. //|__________________________________________________________________________
  53.  
  54. void CRotateMouseTask::KeepTracking(LongPt *current_point, LongPt *previous_point,
  55.                                         LongPt *start_point)
  56. {
  57.  
  58.     long horiz_delta = current_point->h -
  59.                         previous_point->h;                //  Find mouse movement since last time
  60.     long vert_delta = current_point->v -
  61.                         previous_point->v;
  62.  
  63.     drawing_disabled = TRUE;                            //  Don't draw until all changes made
  64.  
  65.     long i;
  66.     for (i = 0; i < num_h; i++)
  67.         h_tasks[i].controls_director->
  68.                 OffsetScrollBar(h_tasks[i].angle,
  69.                     horiz_delta*h_tasks[i].multiplier);    //  Nudge the scroll bar
  70.  
  71.     for (i = 0; i < num_v; i++)
  72.         v_tasks[i].controls_director->
  73.                 OffsetScrollBar(v_tasks[i].angle,
  74.                     vert_delta*v_tasks[i].multiplier);    //  Nudge the scroll bar
  75.  
  76.     drawing_disabled = FALSE;                            //  Redraw the object
  77.     pane->Prepare();
  78.     pane->Draw((Rect *) NULL);
  79.  
  80.  
  81. }    //==== CRotateMouseTask::KeepTracking() ====\\
  82.  
  83.  
  84.  
  85. //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  86. //| CRotateMouseTask::EndTracking
  87. //|
  88. //| Purpose: This gets called when the mouse button is released.
  89. //|
  90. //| Parameters: none
  91. //|______________________________________________________________
  92.  
  93. void CRotateMouseTask::EndTracking(LongPt *current_point, LongPt *previous_point,
  94.                                         LongPt *start_point)
  95. {
  96.  
  97.     KeepTracking(current_point, previous_point, start_point);
  98.  
  99. }    //==== CRotateMouseTask::EndTracking() ====\\
  100.  
  101.  
  102.  
  103.